home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fritz: All Fritz
/
All Fritz.zip
/
All Fritz
/
FILES
/
PROGMISC
/
PCSSP.LZH
/
PC-SSP.ZIP
/
POLYOPS.ZIP
/
PDIV.FOR
< prev
next >
Wrap
Text File
|
1985-11-29
|
2KB
|
82 lines
C
C ..................................................................
C
C SUBROUTINE PDIV
C
C PURPOSE
C DIVIDE ONE POLYNOMIAL BY ANOTHER
C
C USAGE
C CALL PDIV(P,IDIMP,X,IDIMX,Y,IDIMY,TOL,IER)
C
C DESCRIPTION OF PARAMETERS
C P - RESULTANT VECTOR OF INTEGRAL PART
C IDIMP - DIMENSION OF P
C X - VECTOR OF COEFFICIENTS FOR DIVIDEND POLYNOMIAL,
C ORDERED FROM SMALLEST TO LARGEST POWER. IT IS
C REPLACED BY REMAINDER AFTER DIVISION.
C IDIMX - DIMENSION OF X
C Y - VECTOR OF COEFFICIENTS FOR DIVISOR POLYNOMIAL,
C ORDERED FROM SMALLEST TO LARGEST POWER
C IDIMY - DIMENSION OF Y
C TOL - TOLERANCE VALUE BELOW WHICH COEFFICIENTS ARE
C ELIMINATED DURING NORMALIZATION
C IER - ERROR CODE. 0 IS NORMAL, 1 IS FOR ZERO DIVISOR
C
C REMARKS
C THE REMAINDER R REPLACES X.
C THE DIVISOR Y REMAINS UNCHANGED.
C IF DIMENSION OF Y EXCEEDS DIMENSION OF X, IDIMP IS SET TO
C ZERO AND CALCULATION IS BYPASSED
C
C SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C PNORM
C
C METHOD
C POLYNOMIAL X IS DIVIDED BY POLYNOMIAL Y GIVING INTEGER PART
C P AND REMAINDER R SUCH THAT X = P*Y + R.
C DIVISOR Y AND REMAINDER VECTOR GET NORMALIZED.
C
C ..................................................................
C
SUBROUTINE PDIV(P,IDIMP,X,IDIMX,Y,IDIMY,TOL,IER)
DIMENSION P(1),X(1),Y(1)
C
CALL PNORM (Y,IDIMY,TOL)
IF(IDIMY) 50,50,10
10 IDIMP=IDIMX-IDIMY+1
IF(IDIMP) 20,30,60
C
C DEGREE OF DIVISOR WAS GREATER THAN DEGREE OF DIVIDEND
C
20 IDIMP=0
30 IER=0
40 RETURN
C
C Y IS ZERO POLYNOMIAL
C
50 IER=1
GO TO 40
C
C START REDUCTION
C
60 IDIMX=IDIMY-1
I=IDIMP
70 II=I+IDIMX
P(I)=X(II)/Y(IDIMY)
C
C SUBTRACT MULTIPLE OF DIVISOR
C
DO 80 K=1,IDIMX
J=K-1+I
X(J)=X(J)-P(I)*Y(K)
80 CONTINUE
I=I-1
IF(I) 90,90,70
C
C NORMALIZE REMAINDER POLYNOMIAL
C
90 CALL PNORM(X,IDIMX,TOL)
GO TO 30
END